<%--
  Created by IntelliJ IDEA.
  User: HW
  Date: 2025/3/4
  Time: 20:51
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户注册</title>
    <style>
        /* 基础重置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        /* 全屏背景 */
        body {
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background:
                    linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
                    url('pic/bg.jpg') center/cover fixed;
        }

        /* 表单容器 */
        #registerForm {
            background: rgba(255, 255, 255, 0.95);
            padding: 2.5rem 2rem;
            border-radius: 12px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
            backdrop-filter: blur(10px);
        }

        /* 标题样式 */
        h2 {
            text-align: center;
            color: #2c3e50;
            margin-bottom: 1.8rem;
            font-size: 1.8rem;
        }

        /* 输入框组 */
        .input-group {
            margin-bottom: 1.5rem;
        }

        label {
            display: block;
            margin-bottom: 0.5rem;
            color: #34495e;
            font-weight: 500;
        }

        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 0.8rem;
            border: 2px solid #e0e0e0;
            border-radius: 6px;
            font-size: 1rem;
            transition: border-color 0.3s ease;
        }

        input:focus {
            outline: none;
            border-color: #3498db;
            box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
        }

        /* 注册按钮 */
        button[type="submit"] {
            width: 100%;
            padding: 0.9rem;
            background: #3498db;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 1rem;
            font-weight: 500;
            cursor: pointer;
            transition: background 0.3s ease;
        }

        button[type="submit"]:hover {
            background: #2980b9;
        }

        /* 错误提示 */
        #msg {
            display: block;
            margin-top: 1rem;
            padding: 0.5rem;
            background: #e74c3c;
            color: white;
            border-radius: 4px;
            font-size: 0.9rem;
            text-align: center;
        }

        /* 响应式设计 */
        @media (max-width: 480px) {
            #registerForm {
                margin: 1rem;
                padding: 1.5rem;
            }
        }
    </style>
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
<form action="register" method="post" id="registerForm">
    <h2>用户注册</h2>
    <div class="input-group">
        <label for="uname">用户名</label>
        <input type="text" id="uname" name="uname" placeholder="请输入用户名">
    </div>
    <div class="input-group">
        <label for="upwd">密码</label>
        <input type="password" id="upwd" name="upwd" placeholder="请输入密码">
    </div>
    <div class="input-group">
        <label for="upwd2">确认密码</label>
        <input type="password" id="upwd2" name="upwd2" placeholder="请再次输入密码" required>
    </div>
    <button type="submit" id="registerBtn">立即注册</button>
    <span id="msg">${messageModel.msg}</span>
</form>

<script src="JS/jquery.js"></script>
<script type="text/javascript">
    // 保持原有验证逻辑不变
    function isEmpty(str) {
        return str == null || str.trim() === "";
    }

    $("#registerBtn").click(function (event) {
        event.preventDefault();
        $("#msg").html("");

        var uname = $("#uname").val();
        var upwd = $("#upwd").val();
        var upwd2 = $("#upwd2").val();

        if (isEmpty(uname)) {
            $("#msg").html("用户名不可为空！");
            return false;
        }

        if (upwd !== upwd2) {
            $("#msg").html("两次输入密码不一致！");
            return false;
        }

        $("#registerForm").submit();
    });
</script>
</body>
</html>